# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=opencl-headers
pkgbase=mingw-w64-${_realname}
pkgname=${MINGW_PACKAGE_PREFIX}-${_realname}
pkgver=2022.01.04
_clhpp_ver=2.0.16
pkgrel=1
epoch=2
pkgdesc='OpenCL (Open Computing Language) header files'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url='https://www.khronos.org/registry/cl/'
license=('Apache 2.0')
makedepends=("${MINGW_PACKAGE_PREFIX}-cmake"
             "${MINGW_PACKAGE_PREFIX}-ninja"
             "${MINGW_PACKAGE_PREFIX}-cc")
source=(OpenCL-Headers-${pkgver}.tar.gz::https://github.com/KhronosGroup/OpenCL-Headers/archive/refs/tags/v${pkgver}.tar.gz
        OpenCL-CLHPP-${_clhpp_ver}.tar.gz::https://github.com/KhronosGroup/OpenCL-CLHPP/archive/refs/tags/v${_clhpp_ver}.tar.gz)
sha256sums=('6E716E2B13FC8D363B40A165CA75021B102F9328E2B38F8054D7DB5884DE29C9'
            '869456032E60787EED9FCEAEAF6C6CB4452BC0FF97E0F5A271510145A1C8F4D4')

package() {
  cd "${srcdir}"/OpenCL-Headers-${pkgver}

  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
    ${MINGW_PREFIX}/bin/cmake \
      -G'Ninja' \
      -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
      "${extra_config[@]}" \
      -DBUILD_TESTING=OFF \
      ../${_realname}-${pkgver}

  DESTDIR=${pkgdir} cmake --install .

  cd "${srcdir}"/OpenCL-CLHPP-${_clhpp_ver}
  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
    ${MINGW_PREFIX}/bin/cmake \
      -G'Ninja' \
      -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
      "${extra_config[@]}" \
      -DBUILD_TESTS=OFF \
      ../OpenCL-CLHPP-${_clhpp_ver}

  DESTDIR=${pkgdir} cmake --install .

  install -D -m644 "${srcdir}"/OpenCL-Headers-${pkgver}/LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
